package tech.aistar.corejava.day03;

import static tech.aistar.corejava.day03.IsLeapYear.isLeapYear;

/**
* @Description:    作用描述:某年某月某日是某年的第几天
* @Author:          lya
* @CreateDate:     2019/7/17 15:10
* @Version:        1.0
*/
public class DaysDemo {
    public static void main(String[] args) {
        maxday(2012,2,25);
    }
    public static  int maxday(int year,int month,int day){
        int sumDay = 0;
        int[] days = new int[]{31,29,31,30,31,30,31,31,30,31,30,31};
        if(month == 1){
            System.out.println(year+"年"+month+"月"+day+"日是"+year+"年的第"+day+"天");
        }else if(month == 2){
            System.out.println(year+"年"+month+"月"+day+"日是"+year+"年的第"+(days[0]+day)+"天");
        }else{
            if(isLeapYear(year)){
                for(int i = 0;i < month-1;i++){
                    sumDay = sumDay + days[i];
                }
                sumDay = sumDay + day;
                System.out.println(year+"年"+month+"月"+day+"日是"+year+"年的第"+sumDay+"天");
            }else {
                System.out.println(year+"年"+month+"月"+day+"日是今年的第"+(sumDay-1)+"天");
            }
        }
        return sumDay;
    }
}
